package com.refusea.train.controller

import com.refusea.train.domain.helper.RegisterHelper
import com.refusea.train.domain.req.RegisterReq
import com.refusea.train.domain.vo.RegInfo
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * @author Zhang Yan 2024/3/23
 **/
@RestController
@RequestMapping("/api")
class RegisterController(private val registerHelper: RegisterHelper) {

    @PostMapping("/register")
    fun register(@RequestBody req: RegisterReq) {
        registerHelper.register(req)
    }

    /**
     * @param cat
     *  1=parent with referrer code,
     *  2=child with parent id,
     *  3=teacher with school id,
     *  4=referrer with school id,
     */
    @GetMapping("/reg_info")
    fun regInfo(cat: Int, code: String): RegInfo {
        return registerHelper.regInfo(cat, code)
    }

}
